body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Inter', sans-serif;
    user-select: none;
    cursor: default;
}

/* Prevent image dragging globally */
img {
    -webkit-user-drag: none;
    user-select: none;
    pointer-events: none;
}

#desktop {
    width: 100%;
    height: 100%;
    background: url('desktop_wallpaper.png') no-repeat center center;
    background-size: cover;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s ease-in-out;
}

#windows-container {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none !important; /* Let clicks pass through to desktop */
}

#drag-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: none;
}

/* --- Login Screen --- */
#login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('desktop_wallpaper.png') no-repeat center center;
    background-size: cover;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    z-index: 2000;
    transition: opacity 0.5s ease-in-out, visibility 0.5s;
}

#login-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.2);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.login-box {
    position: relative;
    text-align: center;
    color: white;
}

.user-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.5);
    margin: 0 auto 20px auto;
    background-color: rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
}

.user-avatar::before {
    content: '';
    position: absolute;
    top: 25px;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
}

.user-avatar::after {
    content: '';
    position: absolute;
    bottom: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
}

.user-name {
    font-size: 24px;
    font-weight: 500;
    margin: 0 0 15px 0;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    transition: width 0.3s ease, height 0.3s ease, top 0.3s ease, left 0.3s ease;
}

#password-input {
    border: 1px solid rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 10px 15px;
    width: 200px;
    color: white;
    font-size: 14px;
    text-align: center;
}

#password-input::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

/* --- Fullscreen Overlay --- */
#fullscreen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 3000;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    text-align: center;
    cursor: pointer;
}

.fullscreen-box {
    max-width: 400px;
}

.fullscreen-box h1 {
    font-size: 32px;
    margin-bottom: 10px;
}

.fullscreen-box p {
    font-size: 16px;
    color: #ccc;
    margin-bottom: 30px;
}

#enter-fullscreen-btn {
    display: none;
}

/* --- Top Bar --- */
#top-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 28px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    font-size: 14px;
    color: #222;
    box-sizing: border-box;
    z-index: 1000;
    transition: opacity 0.5s ease-in-out;
}

#top-bar .menu, #top-bar .status-icons {
    display: flex;
    gap: 15px;
    align-items: center;
}
.time-display {
    width: 75px;
    text-align: right;
}
#top-bar .status-icons {
    font-variant-numeric: tabular-nums;
}
#top-bar .app-name {
    font-weight: 700;
}
#top-bar .apple-logo {
    font-size: 18px;
}

/* --- Dock --- */
#dock-container {
    position: fixed;
    bottom: 8px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    z-index: 999;
    transition: opacity 0.5s ease-in-out;
}

#dock {
    display: flex;
    gap: 12px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.dock-item {
    position: relative;
    cursor: pointer;
}

.dock-item img {
    width: 60px;
    height: 60px;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    object-fit: contain; /* Prevent stretching */
}

.dock-item:hover img {
    transform: scale(1.5) translateY(-10px);
}

.dock-item .tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) scale(0.8);
    background-color: #333;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    margin-bottom: 15px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, transform 0.2s;
    white-space: nowrap;
}

.dock-item:hover .tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) scale(1);
}

/* General Helper Class */
.hidden {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* --- Custom Scrollbars --- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.4);
}

/* --- Window --- */
.window {
    position: absolute;
    background: rgba(245, 245, 245, 0.8);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    min-width: 300px;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    pointer-events: all; /* Windows should be interactive */
    animation: open-window 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: center center;
    transition: width 0.3s ease, height 0.3s ease, top 0.3s ease, left 0.3s ease;
    box-sizing: border-box;
}

.window.resizing,
.window.dragging {
    transition: none !important;
}

.window.closing {
    animation: close-window 0.3s ease-out forwards;
}

.flicker-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(255, 255, 255, 0.8);
    opacity: 0;
    pointer-events: none;
    z-index: 50000;
    animation: flicker 0.2s steps(2, end) forwards;
}

@keyframes flicker {
    0% { opacity: 0.7; }
    25% { opacity: 0.2; }
    50% { opacity: 0.8; }
    75% { opacity: 0.3; }
    100% { opacity: 0; }
}

@keyframes open-window {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes close-window {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.95);
    }
}

.title-bar {
    height: 35px;
    width: 100%;
    display: flex;
    align-items: center;
    padding: 0 12px;
    box-sizing: border-box;
    cursor: grab;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    justify-content: flex-end; /* Align controls to the right */
}

.title-bar:active {
    cursor: grabbing;
}

.window-controls {
    display: flex;
    gap: 8px;
    order: 2; /* Puts controls at the end */
}

.control-btn {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: none;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Segoe UI Symbol', sans-serif; /* For better symbols */
    font-size: 16px;
    line-height: 20px; /* Vertically center content */
    cursor: pointer;
    background: transparent;
    transition: background-color 0.2s;
}

.control-btn:hover {
    background-color: rgba(0,0,0,0.1);
}

.close:hover { 
    background-color: #e81123 !important; 
    color: white; 
}
.minimize { 
    color: #555; 
}
.maximize { 
    color: #555; 
    font-size: 12px; 
}

.window-title {
    flex-grow: 1;
    text-align: left; /* Title on the left */
    font-weight: 500;
    color: #333;
    font-size: 14px;
    padding-left: 8px;
    order: 1; /* Puts title before controls */
}

.window-content {
    padding: 0; /* Remove padding for custom content layouts */
    flex-grow: 1;
    color: #333;
    font-size: 16px;
    display: flex;
    overflow: hidden;
    position: relative;
}

@keyframes shake {
    0% { transform: translate(1px, 1px) rotate(0deg); }
    10% { transform: translate(-1px, -2px) rotate(-1deg); }
    20% { transform: translate(-3px, 0px) rotate(1deg); }
    30% { transform: translate(3px, 2px) rotate(0deg); }
    40% { transform: translate(1px, -1px) rotate(1deg); }
    50% { transform: translate(-1px, 2px) rotate(-1deg); }
    60% { transform: translate(-3px, 1px) rotate(0deg); }
    70% { transform: translate(3px, 1px) rotate(-1deg); }
    80% { transform: translate(-1px, -1px) rotate(1deg); }
    90% { transform: translate(1px, 2px) rotate(0deg); }
    100% { transform: translate(1px, -2px) rotate(-1deg); }
}

/* --- Window Resizers --- */
.resizer {
    position: absolute;
    width: 10px;
    height: 10px;
}
.resizer-r {
    top: 0;
    right: -5px;
    bottom: 0;
    width: 10px;
    cursor: ew-resize;
}
.resizer-b {
    left: 0;
    right: 0;
    bottom: -5px;
    height: 10px;
    cursor: ns-resize;
}
.resizer-br {
    bottom: -5px;
    right: -5px;
    cursor: nwse-resize;
    z-index: 10;
}

#big-cookie:active {
    transform: scale(0.95);
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.floating-text {
    position: absolute;
    font-size: 24px;
}